package com.aoxin.controller.opm;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.aoxin.model.opm.SlfClassroomSyllabusDate;
import com.aoxin.service.inter.opm.ClassroomSyllabusDateService;
import com.aoxin.util.AjaxRes;
import com.aoxin.util.enumerate.OperateType;
import com.aoxin.util.log.LogInfo;

@Controller
@ResponseBody
@RequestMapping("/web/classroomSyllabusDate/")
public class ClassroomSyllabusDateController {

    @Autowired
    ClassroomSyllabusDateService classroomSyllabusDateService;


    /**
     * 新增教室上课时间关联信息
     * @param classroomId
     * @param syllabusDateIds
     * @param res
     * @return
     */
    @RequestMapping("insertClassroomSyllabusDate")
    @LogInfo(content = "教室上课时间关联",operateType = OperateType.INSERT)
    public AjaxRes insertClassroomSyllabusDate(@RequestParam("classroomId") Integer classroomId,@RequestParam("syllabusDateIds") List<Integer> syllabusDateIds, AjaxRes res){
        if(classroomId != null && syllabusDateIds != null && syllabusDateIds.size() > 0){
            Integer result = classroomSyllabusDateService.insertClassroomSyllabusDate(classroomId,syllabusDateIds);
            if(result != 0){
                res.setSucceedMsg("添加教室上课时间关联信息成功!");
            }else {
                res.setFailMsg("添加加教室上课时间关联信息失败!");
            }
        }else {
            res.setFailMsg("参数为空!");
        }
        return res;
    }


    /**
     * 删除教室上课时间关联关系
     * @param classroomSyllabusDateIds
     * @param res
     * @return
     */
    @RequestMapping("deleteClassroomSyllabusDate")
    @LogInfo(content = "教室上课时间关联",operateType = OperateType.DELETE)
    public AjaxRes deleteClassroomSyllabusDate(@RequestParam("classroomSyllabusDateIds") List<Integer> classroomSyllabusDateIds,AjaxRes res){
        if(classroomSyllabusDateIds != null && classroomSyllabusDateIds.size() > 0){
            Integer result =classroomSyllabusDateService.deleteClassroomSyllabusDate(classroomSyllabusDateIds);
            if(result != 0){
                res.setSucceedMsg("删除教室上课时间关联信息成功!");
            }else {
                res.setFailMsg("添加加教室上课时间关联信息失败!");
            }
        }else {
            res.setFailMsg("参数为空!");
        }
        return res;
    }


    /**
     * 查询教室上课时间关联
     * @param slfClassroomSyllabusDate
     * @param pageInfo
     * @param res
     * @return
     */
    @RequestMapping("getClassroomSyllabusDate")
    @LogInfo(content = "教室上课时间关联",operateType = OperateType.QUERY)
    public AjaxRes getClassroomSyllabusDate(SlfClassroomSyllabusDate slfClassroomSyllabusDate,AjaxRes res){
        List<SlfClassroomSyllabusDate> slfClassroomSyllabusDatePageInfo = classroomSyllabusDateService.getSlfClassroomSyllabusDate(slfClassroomSyllabusDate);
        if(slfClassroomSyllabusDatePageInfo != null && slfClassroomSyllabusDatePageInfo.size() >0){
            res.setSucceed(slfClassroomSyllabusDatePageInfo,"getClassroomSyllabusDate success!");
        }else {
            res.setFailMsg("获取数据失败!");
        }
        return res;
    }

}
